package com.ruoyi.netty.config;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;


/**
 * @Author ung
 * @Description: 生产者
 */
@Configuration
public class ProducerConfig {

    // 声明交换机
    @Bean
    public Queue FirstQueue(){
        return new Queue("queue1");
    }
    @Bean
    public Queue TwoQueue(){
        return new Queue("queue2");
    }
    @Bean
    public Queue ThreeQueue(){
        return new Queue("queue3");
    }
    // 声明交换机
    @Bean
    public DirectExchange businessExchange(){
        return new DirectExchange("businessExchange");
    }
    //  交换机绑定队列 并设置Key
    @Bean
    public Binding bindFirstExchange(){
        return  BindingBuilder.bind(FirstQueue()).to(businessExchange()).with("k1");
    }
    @Bean
    public Binding bindTwoExchange(){
        return  BindingBuilder.bind(TwoQueue()).to(businessExchange()).with("k2");
    }
    @Bean
    public Binding bindThreeExchange(){
        return  BindingBuilder.bind(ThreeQueue()).to(businessExchange()).with("k3");
    }

}
